/*
 * This file is used to define the the class that used by TUI framework
 * Detailed Instruct pls read DOC and class notes
 * Light INLINE code pls defined here
 * Noticed that this is only tested Under Windows
 * Linux Compebility is NOT guaranteed.

    NOTICE  TODO:  UPDATE  Need to be seprated and rewrite

 */

#ifdef __GET__WINDOWH__
#define WARNING__REDEFINE
#endif
#ifndef __GET__WINDOWH__
#define __GET__WINDOWH__


#ifdef _WIN32
#include <windows.h>
struct winsize
{
    unsigned short ws_row;    /* 行数 */
    unsigned short ws_col;    /* 列数 */
    unsigned short ws_xpixel; /* 水平像素数 */
    unsigned short ws_ypixel; /* 垂直像素数 */
};
#else
#include <sys/ioctl.h>
#include <unistd.h>
#endif

#include "DataStructureH/attributes.h"

//----- [START] ------------Coord Interpretor------------

inline int &_CoordInterp(Coord_t const &TargetPos, Coord_t const &WindowSize, int &OutPutIndex)
{
	OutPutIndex = TargetPos.Y*WindowSize.X + TargetPos.X;
    return OutPutIndex;
}

// Disposable Version of coordinterpretor
inline int _CoordInterp(Coord_t const &TargetPos, Coord_t const &WindowSize)
{
    int OutPutIndex = TargetPos.Y * WindowSize.X + TargetPos.X;
	return OutPutIndex;
}
//-----  [END]  -------------------------------------------



//----- [START] ------------Cursor Control------------
inline int CursorJumpTo(Coord_t const &coord)
{
#ifdef _WIN32
    COORD wincoord{coord.X,coord.Y};
    SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), wincoord);
    #else
    printf("\033[%d;%dH", coord.X, coord.Y);
#endif
    return 0;
}
//-----  [END]  --------------------------------------



//Base Structure


#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"




#pragma GCC diagnostic pop

#endif